// Thor - High Performance C++ containers and algorithm library.
//
// Copyright (c) 2010 Su Shi. All rights reserved.
//
// Author: Su Shi <carmack.shi [at] gmail.com>

// GTest
#include <gtest/gtest.h>

// Thor
#include <thor_binomial_heap.h>

typedef thor::BinomialHeap<int> IBHeap;

TEST(IBHeapTest, Minimum) {
  IBHeap ib_heap;

  // Insert some elements in any order.
  for (int elem = -128; elem <= 128; elem += 32)
    ib_heap.Insert(elem);

  IBHeap::Iterator it = ib_heap.Minimum();
  EXPECT_EQ(-128, *it);
}

TEST(IBHeapTest, ExtractMinimum) {
  IBHeap ib_heap;

  // Insert some elements in any order.
  for (int elem = -128; elem <= 128; elem += 32)
    ib_heap.Insert(elem);

  EXPECT_EQ(-128, *ib_heap.Minimum());

  ib_heap.ExtractMinimum();

  EXPECT_EQ(-96, *ib_heap.Minimum());
}

TEST(IBHeapTest, Delete) {
  IBHeap ib_heap;

  // Insert some elements in any order.
  for (int elem = -128; elem <= 128; elem += 32)
    ib_heap.Insert(elem);

  IBHeap::Iterator it = ib_heap.Minimum();
  EXPECT_EQ(-128, *it);

  ib_heap.Delete(it);
  it = ib_heap.Minimum();
  EXPECT_EQ(-96, *it);
}
